#ifndef TILESHEET_H
#define TILESHEET_H
#include <QtOpenGL/qgl.h>
#include <GLWindow.h>
#include <Image.h>
#include <string>
#include "Tile.h"
#include "Camera.h"
#include <QScrollBar>

class TileSheet : public GLWindow
{
    Q_OBJECT
public:
    TileSheet(QWidget* parent =0);
    ~TileSheet();

    void SetImage(std::string name);

    void SelectTile(int mouseX, int mouseY);

    Image &GetImage() { return *myImage; }

    TileRect &GetRect(int index);

    TileRect &GetSelected();

    void SetupRects();

    int GetTileID();
    void SetSize(int s) { size = s; }

public slots:
    void MoveCameraX(int x);
    void MoveCameraY(int x);

protected:
    void paintGL();
    void initializeGL();

    void mousePressEvent(QMouseEvent*);

private:
    Image* myImage;
    std::vector<TileRect> myRects;
    int myCurrent;
    int size;
    QString myDir;
    Camera myCamera;
    QScrollBar myVerticalScroll;
    QScrollBar myHorizontalScroll;
};

#endif // TILESHEET_H
